package com.gitee.elf.core.entity

import com.gitee.elf.core.entity.EntityManager.bukkitMappingInstance
import com.gitee.elf.core.entity.EntityManager.getEntityInstance
import org.bukkit.event.player.PlayerInteractAtEntityEvent
import org.bukkit.inventory.EquipmentSlot
import taboolib.common.platform.event.SubscribeEvent

object EntityRide {

    @SubscribeEvent
    fun e(e: PlayerInteractAtEntityEvent) {
        if (e.hand == EquipmentSlot.OFF_HAND && e.player.isSneaking) {
            val instance = e.rightClicked.getEntityInstance() ?: return
            instance.bukkitMappingInstance?.addPassenger(e.player)
        }
    }

}